Understanding the structure and properties of geological formations can reduce the cost of drilling wells for oil and gas exploration. Measurements made in a borehole (i.e., downhole measurements) are typically performed to attain this understanding, to identify the composition and distribution of material that surrounds the measurement device downhole. To obtain such measurements, gamma ray detectors are often used to measure naturally-occurring gamma radiation downhole. However, the gain of some gamma ray detectors may fluctuate due to environmental conditions downhole. These fluctuations can cause changes in the apparent energy level detected by the gamma ray detector, thereby leading to inaccuracies in the measurements reported by gamma ray measurement tools.